home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / slapfght.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  4KB  |  143 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12. unsigned char *slapfight_videoram;
  13. unsigned char *slapfight_colorram;
  14. size_t slapfight_videoram_size;
  15. unsigned char *slapfight_scrollx_lo,*slapfight_scrollx_hi,*slapfight_scrolly;
  16.  
  17.  
  18. /***************************************************************************
  19.  
  20.   Convert the color PROMs into a more useable format.
  21.  
  22.   Slapfight has three 256x4 palette PROMs (one per gun) all colours for all
  23.   outputs are mapped to the palette directly.
  24.  
  25.   The palette PROMs are connected to the RGB output this way:
  26.  
  27.   bit 3 -- 220 ohm resistor  -- RED/GREEN/BLUE
  28.         -- 470 ohm resistor  -- RED/GREEN/BLUE
  29.         -- 1  kohm resistor  -- RED/GREEN/BLUE
  30.   bit 0 -- 2.2kohm resistor  -- RED/GREEN/BLUE
  31.  
  32. ***************************************************************************/
  33. void slapfight_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  34. {
  35.     int i;
  36.  
  37.  
  38.     for (i = 0;i < Machine->drv->total_colors;i++)
  39.     {
  40.         int bit0,bit1,bit2,bit3;
  41.  
  42.  
  43.         bit0 = (color_prom[0] >> 0) & 0x01;
  44.         bit1 = (color_prom[0] >> 1) & 0x01;
  45.         bit2 = (color_prom[0] >> 2) & 0x01;
  46.         bit3 = (color_prom[0] >> 3) & 0x01;
  47.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  48.         bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  49.         bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  50.         bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  51.         bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  52.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  53.         bit0 = (color_prom[2*Machine->drv->total_colors] >> 0) & 0x01;
  54.         bit1 = (color_prom[2*Machine->drv->total_colors] >> 1) & 0x01;
  55.         bit2 = (color_prom[2*Machine->drv->total_colors] >> 2) & 0x01;
  56.         bit3 = (color_prom[2*Machine->drv->total_colors] >> 3) & 0x01;
  57.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  58.  
  59.         color_prom++;
  60.     }
  61. }
  62.  
  63.  
  64.  
  65.  
  66. /***************************************************************************
  67.  
  68.   Draw the game screen in the given osd_bitmap.
  69.   Do NOT call osd_update_display() from this function, it will be called by
  70.   the main emulation engine.
  71.  
  72. ***************************************************************************/
  73. void slapfight_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  74. {
  75.     int offs;
  76.  
  77.  
  78.     /* for every character in the Video RAM, check if it has been modified */
  79.     /* since last time and update it accordingly. */
  80.     for (offs = videoram_size - 1;offs >= 0;offs--)
  81.     {
  82.         if (dirtybuffer[offs])
  83.         {
  84.             int sx,sy;
  85.  
  86.  
  87.             dirtybuffer[offs] = 0;
  88.  
  89.             sx = offs % 64;
  90.             sy = offs / 64;
  91.  
  92.             drawgfx(tmpbitmap,Machine->gfx[1],
  93.                     videoram[offs] + ((colorram[offs] & 0x0f) << 8),
  94.                     (colorram[offs] & 0xf0) >> 4,
  95.                     0,0,
  96.                     8*sx,8*sy,
  97.                     0,TRANSPARENCY_NONE,0);
  98.         }
  99.     }
  100.  
  101.  
  102.     /* copy the temporary bitmap to the screen */
  103.     {
  104.         int scrollx,scrolly;
  105.  
  106.  
  107.         scrollx = -(*slapfight_scrollx_lo + 256 * *slapfight_scrollx_hi);
  108.         scrolly = -*slapfight_scrolly+1;
  109.         copyscrollbitmap(bitmap,tmpbitmap,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  110.     }
  111.  
  112.  
  113.     /* Draw the sprites */
  114.     for (offs = 0;offs < spriteram_size;offs += 4)
  115.     {
  116.         drawgfx(bitmap,Machine->gfx[2],
  117.             spriteram[offs] + ((spriteram[offs+2] & 0xc0) << 2),
  118.             (spriteram[offs+2] & 0x1e) >>1,
  119.             0,0,
  120.         /* Mysterious fudge factor sprite offset */
  121.             (spriteram[offs+1] + ((spriteram[offs+2] & 0x01) << 8)) - 13,spriteram[offs+3],
  122.             &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  123.     }
  124.  
  125.  
  126.     /* draw the frontmost playfield. They are characters, but draw them as sprites */
  127.     for (offs = slapfight_videoram_size - 1;offs >= 0;offs--)
  128.     {
  129.         int sx,sy;
  130.  
  131.  
  132.         sx = offs % 64;
  133.         sy = offs / 64;
  134.  
  135.         drawgfx(bitmap,Machine->gfx[0],
  136.             slapfight_videoram[offs] + ((slapfight_colorram[offs] & 0x03) << 8),
  137.             (slapfight_colorram[offs] & 0xfc) >> 2,
  138.             0,0,
  139.             8*sx,8*sy,
  140.             &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  141.     }
  142. }
  143.